home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sprite 1984 - 1993
/
Sprite 1984 - 1993.iso
/
src
/
lib
/
c
/
stdio
/
RCS
/
ftell.c,v
< prev
next >
Wrap
Text File
|
1991-12-02
|
4KB
|
193 lines
head 1.5;
branch ;
access ;
symbols sprited:1.5.1;
locks ; strict;
comment @ * @;
1.5
date 88.07.29.18.56.38; author ouster; state Exp;
branches 1.5.1.1;
next 1.4;
1.4
date 88.07.28.16.48.47; author ouster; state Exp;
branches ;
next 1.3;
1.3
date 88.07.25.13.12.55; author ouster; state Exp;
branches ;
next 1.2;
1.2
date 88.07.11.09.11.07; author ouster; state Exp;
branches ;
next 1.1;
1.1
date 88.06.10.16.23.52; author ouster; state Exp;
branches ;
next ;
1.5.1.1
date 91.12.02.19.58.22; author kupfer; state Exp;
branches ;
next ;
desc
@@
1.5
log
@Lint.
@
text
@/*
* ftell.c --
*
* Source code for the "ftell" library procedure.
*
* Copyright 1988 Regents of the University of California
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies. The University of California
* makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without
* express or implied warranty.
*/
#ifndef lint
static char rcsid[] = "$Header: ftell.c,v 1.4 88/07/28 16:48:47 ouster Exp $ SPRITE (Berkeley)";
#endif not lint
#include "stdio.h"
#include "fileInt.h"
#include <sys/file.h>
extern long ftell(), lseek();
/*
*----------------------------------------------------------------------
*
* ftell --
*
* This procedure returns the current access position in a file
* stream, as a byte count from the beginning of the file.
*
* Results:
* The return value is the location (measured in bytes from the
* beginning of the file associated with stream) where the next
* byte will be read or written. If the stream doesn't
* correspond to a file, or if there is an error during the operation,
* then -1 is returned.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
long
ftell(stream)
register FILE *stream;
{
int count;
if ((stream->readProc != (void (*)()) StdioFileReadProc) ||
((stream->flags & (STDIO_READ|STDIO_WRITE)) == 0)) {
return -1;
}
count = lseek((int) stream->clientData, 0L, L_INCR);
if (count < 0) {
return -1;
}
/*
* The code is different for reading and writing. For writing,
* we add the system's idea of current position to the number
* of bytes waiting in the buffer. For reading, subtract the
* number of bytes still available in the buffer from the system's
* idea of the current position.
*/
if (stream->writeCount > 0) {
count += stream->lastAccess + 1 - stream->buffer;
} else if (stream->readCount > 0) {
count -= stream->readCount;
}
return(count);
}
@
1.5.1.1
log
@Initial branch for Sprite server.
@
text
@d17 1
a17 1
static char rcsid[] = "$Header: /sprite/src/lib/c/stdio/RCS/ftell.c,v 1.5 88/07/29 18:56:38 ouster Exp $ SPRITE (Berkeley)";
@
1.4
log
@Lint cleanup.
@
text
@d17 1
a17 1
static char rcsid[] = "$Header: ftell.c,v 1.3 88/07/25 13:12:55 ouster Exp $ SPRITE (Berkeley)";
d58 1
a58 1
count = lseek((int) stream->clientData, 0, L_INCR);
@
1.3
log
@Lint.
@
text
@d17 1
a17 1
static char rcsid[] = "$Header: ftell.c,v 1.2 88/07/11 09:11:07 ouster Exp $ SPRITE (Berkeley)";
d24 1
a24 1
extern long ftell();
@
1.2
log
@Change to return long instead of int.
@
text
@d17 1
a17 1
static char rcsid[] = "$Header: ftell.c,v 1.1 88/06/10 16:23:52 ouster Exp $ SPRITE (Berkeley)";
d23 2
@
1.1
log
@Initial revision
@
text
@d17 1
a17 1
static char rcsid[] = "$Header: atoi.c,v 1.1 88/04/28 17:20:23 ouster Exp $ SPRITE (Berkeley)";
d45 1
a45 1
int
@